<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">

<script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
<link href="//cdn.bootcss.com/pace/1.0.2/themes/pink/pace-theme-flash.css" rel="stylesheet">
<meta name="theme-color" content="#fff">
<meta name="generator" content="Hexo 5.4.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/favicon.ico">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon.ico">
  <link rel="mask-icon" href="/images/logo.svg" color="#fff">

<link rel="stylesheet" href="/css/main.css">

<link rel="stylesheet" href="https://fonts.cat.net/css?family=Lato:300,300italic,400,400italic,700,700italic%7CRoboto+Slab:300,300italic,400,400italic,700,700italic%7CDejaVu+Sans+Mono:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext">

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.3/css/all.min.css" integrity="sha256-2H3fkXt6FEmrReK448mDVGKb3WW2ZZw35gI7vqHOE4Y=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.css" integrity="sha256-no0c5ccDODBwp+9hSmV5VvPpKwHCpbVzXHexIkupM6U=" crossorigin="anonymous">
  <script src="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.js" integrity="sha256-a5YRB27CcBwBFcT5EF/f3E4vzIqyHrSR878nseNYw64=" crossorigin="anonymous"></script>

<script class="next-config" data-name="main" type="application/json">{"hostname":"hyw-zero.github.io","root":"/","images":"/images","scheme":"Gemini","version":"8.7.0","exturl":false,"sidebar":{"position":"left","display":"hide","padding":10,"offset":12,"scrollpercent":false,"onmobile":false},"copycode":true,"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>
<meta name="description" content="1.vim简介Vim是从 vi 发展出来的一个文本编辑器。代码补全、编译及错误跳转等方便编程的功能特别丰富，在程序员中被广泛使用，和Emacs并列成为类Unix系统用户最喜欢的文本编辑器之一。vim的设计理念是命令的组合。用户学习了各种各样的文本间移动&#x2F;跳转的命令和其他的普通模式的编辑命令，并且能够灵活组合使用的话，能够比那些没有模式的编辑器更加高效的进行文本编辑。">
<meta property="og:type" content="article">
<meta property="og:title" content="vim常用快捷键">
<meta property="og:url" content="https://hyw-zero.github.io/2019/03/16/vim%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93/index.html">
<meta property="og:site_name" content="ZERO">
<meta property="og:description" content="1.vim简介Vim是从 vi 发展出来的一个文本编辑器。代码补全、编译及错误跳转等方便编程的功能特别丰富，在程序员中被广泛使用，和Emacs并列成为类Unix系统用户最喜欢的文本编辑器之一。vim的设计理念是命令的组合。用户学习了各种各样的文本间移动&#x2F;跳转的命令和其他的普通模式的编辑命令，并且能够灵活组合使用的话，能够比那些没有模式的编辑器更加高效的进行文本编辑。">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2019-03-15T20:11:09.000Z">
<meta property="article:modified_time" content="2021-08-22T09:32:40.596Z">
<meta property="article:author" content="hyw-zero">
<meta property="article:tag" content="vim">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="https://hyw-zero.github.io/2019/03/16/vim%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://hyw-zero.github.io/2019/03/16/vim%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93/","path":"2019/03/16/vim使用总结/","title":"vim常用快捷键"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>vim常用快捷键 | ZERO</title>
  



<script src="https://cdn.jsdelivr.net/gh/stevenjoezhang/live2d-widget@latest/autoload.js"></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<link rel="alternate" href="/atom.xml" title="ZERO" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>
  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">ZERO</h1>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">keep  learning, be  curious !</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu">
        <li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li>
        <li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a></li>
        <li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a></li>
        <li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li>
        <li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#1-vim%E7%AE%80%E4%BB%8B"><span class="nav-text">1.vim简介</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#2-vim%E7%9A%84%E4%BD%BF%E7%94%A8"><span class="nav-text">2.vim的使用</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#2-1-vim%E7%9A%84%E4%BF%9D%E5%AD%98%E9%80%80%E5%87%BA%E5%91%BD%E4%BB%A4"><span class="nav-text">2.1 vim的保存退出命令</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-2-vim%E7%9A%84%E8%BE%85%E5%8A%A9%E6%98%BE%E7%A4%BA%E5%91%BD%E4%BB%A4"><span class="nav-text">2.2 vim的辅助显示命令</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-3-vim%E6%96%87%E6%9C%AC%E6%93%8D%E4%BD%9C%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4"><span class="nav-text">2.3 vim文本操作常用命令</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%85%89%E6%A0%87%E7%A7%BB%E5%8A%A8"><span class="nav-text">光标移动</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%8D%95%E8%AF%8D%E8%B7%B3%E8%BD%AC"><span class="nav-text">单词跳转</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%BF%BB%E9%A1%B5%E6%93%8D%E4%BD%9C"><span class="nav-text">翻页操作</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%BF%AB%E9%80%9F%E8%A1%8C%E8%B7%B3%E8%BD%AC"><span class="nav-text">快速行跳转</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%9F%A5%E6%89%BE"><span class="nav-text">字符串查找</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%A4%8D%E5%88%B6%E4%B8%8E%E7%B2%98%E8%B4%B4%E6%93%8D%E4%BD%9C"><span class="nav-text">复制与粘贴操作</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%88%A0%E9%99%A4%E8%A1%8C%E6%93%8D%E4%BD%9C"><span class="nav-text">删除行操作</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%88%A0%E9%99%A4%E6%8C%87%E5%AE%9A%E8%8C%83%E5%9B%B4%E6%93%8D"><span class="nav-text">删除指定范围操</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BB%A3%E7%A0%81%E8%A1%A5%E5%85%A8%E6%93%8D%E4%BD%9C"><span class="nav-text">代码补全操作</span></a></li></ol></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
            <div class="site-overview">
              <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="hyw-zero"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">hyw-zero</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">13</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">5</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">4</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author site-overview-item animated">
      <span class="links-of-author-item">
        <a href="mailto:hyw33666@gmail.com" title="E-Mail → mailto:hyw33666@gmail.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://github.com/hyw-zero" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;hyw-zero" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>


  <div class="links-of-blogroll site-overview-item animated">
    <div class="links-of-blogroll-title"><i class="fa fa-link fa-fw"></i>
      推荐阅读
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <a href="http://c.biancheng.net/cplus/" title="http:&#x2F;&#x2F;c.biancheng.net&#x2F;cplus&#x2F;" rel="noopener" target="_blank">c语言中文网</a>
        </li>
        <li class="links-of-blogroll-item">
          <a href="https://github.com/chenshuo/documents/downloads" title="https:&#x2F;&#x2F;github.com&#x2F;chenshuo&#x2F;documents&#x2F;downloads" rel="noopener" target="_blank">Linux多线程服务端</a>
        </li>
        <li class="links-of-blogroll-item">
          <a href="https://github.com/SilverMaple/STLSourceCodeNote" title="https:&#x2F;&#x2F;github.com&#x2F;SilverMaple&#x2F;STLSourceCodeNote" rel="noopener" target="_blank">STL源码剖析</a>
        </li>
    </ul>
  </div>
<div class="cc-license animated" itemprop="sponsor">
  <a href="https://www.netlify.com" class="cc-opacity" title="Deploy with Netlify → https://www.netlify.com" target="_blank"><img width="80" src="https://www.netlify.com/img/global/badges/netlify-dark.svg" alt="Netlify"></a>
</div>
            </div>
        </div>
	    </div>
	  

    </div>
	<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=280 height=300 src="//music.163.com/outchain/player?type=0&id=411680085&auto=1&height=430"></iframe>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://hyw-zero.github.io/2019/03/16/vim%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="hyw-zero">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="ZERO">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          vim常用快捷键
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2019-03-15 20:11:09" itemprop="dateCreated datePublished" datetime="2019-03-15T20:11:09Z">2019-03-15</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/Linux/" itemprop="url" rel="index"><span itemprop="name">Linux</span></a>
        </span>
    </span>

  
    <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv">
      <span class="post-meta-item-icon">
        <i class="far fa-eye"></i>
      </span>
      <span class="post-meta-item-text">阅读次数：</span>
      <span id="busuanzi_value_page_pv"></span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <h1 id="1-vim简介"><a href="#1-vim简介" class="headerlink" title="1.vim简介"></a>1.vim简介</h1><p>Vim是从 vi 发展出来的一个文本编辑器。代码补全、编译及错误跳转等方便编程的功能特别丰富，在程序员中被广泛使用，和Emacs并列成为类Unix系统用户最喜欢的文本编辑器之一。vim的设计理念是命令的组合。用户学习了各种各样的文本间移动/跳转的命令和其他的普通模式的编辑命令，并且能够灵活组合使用的话，能够比那些没有模式的编辑器更加高效的进行文本编辑。</p>
<span id="more"></span>

<h1 id="2-vim的使用"><a href="#2-vim的使用" class="headerlink" title="2.vim的使用"></a>2.vim的使用</h1><p>在终端（terminal）中，输入 vim 进入vim。vim有两种形式：命令（命令模式）和编辑（编辑模式），一般默认情况下vim是进入命令模式。切换命令和编辑模式的方法是：<br>在键盘上按下  <strong>i</strong>   这时在vim底部会出现insert，表示进入了编辑模式，在这种模式下用户可以进行写操作。<br>在编辑模式时，可以在键盘上按下  <strong>Esc</strong>   进入命令模式。用户可以进行使用vim命令进行操作。保存和退出编辑时需要在命令模式下执行。</p>
<h2 id="2-1-vim的保存退出命令"><a href="#2-1-vim的保存退出命令" class="headerlink" title="2.1 vim的保存退出命令"></a>2.1 vim的保存退出命令</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">:w  表示保存文件的内容并退出vim   </span><br><span class="line">:q  表示退出退出文件并退出vim    </span><br><span class="line">:wq 表示保存并退出文件并退出vim   </span><br><span class="line">:!q 表示不保存文件并退出vim </span><br></pre></td></tr></table></figure>

<blockquote>
<p>注：命令中的<strong>：</strong>不要忽略</p>
</blockquote>
<h2 id="2-2-vim的辅助显示命令"><a href="#2-2-vim的辅助显示命令" class="headerlink" title="2.2 vim的辅助显示命令"></a>2.2 vim的辅助显示命令</h2><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">:syntax on 来实现代码的高亮</span><br><span class="line">:<span class="built_in">set</span> number 来实现vim左侧的行号显示。</span><br></pre></td></tr></table></figure>

<blockquote>
<p>注：的是无论是 :set number 或是 :syntax on 只针对本次操作</p>
</blockquote>
<p><strong>针对vim编辑器进行行号及高量</strong></p>
<p>若想使用vim打开所有的软件都进行代码高亮和行号显示可以对.vimrc文件进行修改。</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">1. vim ~/.vimrc </span><br><span class="line">2. 打开后进入编辑模式输入以下两行内容，如果自己想要添加其他代码提示信息，只需要在末尾追加即可</span><br><span class="line">   ：<span class="built_in">set</span> number </span><br><span class="line">   ：syntax on</span><br><span class="line">3. 切换到命令模式输入:wq，保存退出。</span><br></pre></td></tr></table></figure>

<h2 id="2-3-vim文本操作常用命令"><a href="#2-3-vim文本操作常用命令" class="headerlink" title="2.3 vim文本操作常用命令"></a>2.3 vim文本操作常用命令</h2><h3 id="光标移动"><a href="#光标移动" class="headerlink" title="光标移动"></a>光标移动</h3><p>vim中光标的移动不仅可以用方向键进行上下左右的方式移动，还在命令模式下用以下字母进行光标位置的移动</p>
<pre><code>H 左 
J 下
K 上
L 右 
</code></pre>
<h3 id="单词跳转"><a href="#单词跳转" class="headerlink" title="单词跳转"></a>单词跳转</h3><p>在vim中如果想要一个单词一个单词的方式来移动光标的下一个位置，在命令模式下用以下字母进行光标位置的移动</p>
<pre><code>w  跳转到下一个单词
b  跳转到上一个单词
</code></pre>
<h3 id="翻页操作"><a href="#翻页操作" class="headerlink" title="翻页操作"></a>翻页操作</h3><p>在vim中可以用键盘上得<strong>PageUp</strong>和<strong>PageDown</strong>来进行翻页，vim中还支持其他指令翻页</p>
<pre><code>Crtl+F  进行向下翻页
Crtl+B   进行向上翻页
</code></pre>
<h3 id="快速行跳转"><a href="#快速行跳转" class="headerlink" title="快速行跳转"></a>快速行跳转</h3><p>在vim中可以用以下几种方式跳转到具体某一行</p>
<pre><code>数字+GG  跳转到数字行   25gg 表示跳转到第25行
数字+J   向下多少行     25j  向下跳转25行 
数字+K   向上多少行     24j  向下跳转24行
</code></pre>
<blockquote>
<p>注：取消上述操作按<strong>Esc</strong>键即可取消</p>
</blockquote>
<pre><code>:+数字   跳转到数字行   :25  表示跳转到第25行
</code></pre>
<h3 id="字符串查找"><a href="#字符串查找" class="headerlink" title="字符串查找"></a>字符串查找</h3><p>在vim中，查找某个固定的字符串、单词的操作具体如下 </p>
<pre><code>1./字符串+Enter  所有相同的字符串都将高亮起来，
2.按 N      查找下一个字符串的位置，
3.按Shift+N 查找上一个字符串的位置。
4.找到相应字符串的位置后需要按 Esc 退出命令模式，再按 i 进入编辑模式，进行代 码的编辑。
</code></pre>
<h3 id="复制与粘贴操作"><a href="#复制与粘贴操作" class="headerlink" title="复制与粘贴操作"></a>复制与粘贴操作</h3><p>在vim中，复制行的操作具体如下，在命令模式下</p>
<pre><code>YY      表示复制当前行的操作，复制后会自动进入了编辑模式，
Y数字Y   表示删除当前向下数字行的操作      Y5Y 从光标所示行向下复制5行
P       表示粘贴已经复制好的内容
</code></pre>
<h3 id="删除行操作"><a href="#删除行操作" class="headerlink" title="删除行操作"></a>删除行操作</h3><p>在vim中，进行删除的操作具体如下，在命令模式下</p>
<pre><code>CC      表示删除当前一整行的操作，删除后会自动进入了编辑模式，
C数字C   表示删除当前向下数字行的操作      C5C 从光标所示行向下删除5行
</code></pre>
<blockquote>
<p>注：如果删错了代码的话需要先按   Esc   退出到命令模式，然后按U（表示undo）即可恢复到删除前。CC命令其实是剪切的命令，不是直接删除，内存中仍有一份备份，可以在命令模式下用  P  来粘贴剪切好的代码，如果想撤销粘贴的操作按  U  即可撤销掉。</p>
</blockquote>
<h3 id="删除指定范围操"><a href="#删除指定范围操" class="headerlink" title="删除指定范围操"></a>删除指定范围操</h3><p>在vim中，如果想要删除标号a-标号b之间的代码，在命令模式下如下操作。</p>
<pre><code> 1.按  V  进入VISUAL模式，类似于光标做选择一样，
 2.按  J  或者 K 来进行代码向下向上的选中，
 3.按  C  剪切选中的代码部分，
</code></pre>
<blockquote>
<p>注：如果删除错误的话可以按下  P  粘贴回代码。复制的功能是通过YY按键来实现的，复制了当前的一行。</p>
</blockquote>
<h3 id="代码补全操作"><a href="#代码补全操作" class="headerlink" title="代码补全操作"></a>代码补全操作</h3><p>vim中自带代码补全的功能，</p>
<p>Ctrl+N 自动补全之前出现过的代码，</p>
<blockquote>
<p>注：vim中自带代码补全的功能，功能不够完善可以通过的第三方插件管理来实现代码的自动补全。vim plug就是vim比较重要的插件管理，可以自行在网上查找一下。</p>
</blockquote>

    </div>

    
    
    
	<div>
		
			<div>
	
		<div style="text-align:center;color: #ccc;font-size:16px;">---------------------------------------本文结束<i class="fa fa-paw"></i>感谢您的阅读---------------------------------------</div>
	
</div>
		
	</div>
	<div>
		
			
<div class="my_post_copyright">
<script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>
<!-- JS库 sweetalert 可修改路径 -->
<script src="https://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<p><span>本文标题:</span><a href="/2019/03/16/vim%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93/">vim常用快捷键</a></p>
<!--
<p><span>文章作者:</span><a href="/" title="访问  的个人博客"></a></p>
-->
<p><span>发布时间:</span>2019年03月15日 - 20:11</p>
<p><span>最后更新:</span>2021年08月22日 - 09:32</p>
<p><span>原始链接:</span><a href="/2019/03/16/vim%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93/" title="vim常用快捷键">https://hyw-zero.github.io/2019/03/16/vim%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93/</a>
<span class="copy-path" title="点击复制文章链接"><i class="fa fa-clipboard" data-clipboard-text="https://hyw-zero.github.io/2019/03/16/vim%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93/" aria-label="复制成功！"></i></span>
</p>
<p><span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>
</div>
<script>
var clipboard = new Clipboard('.fa-clipboard');
$(".fa-clipboard").click(function(){
clipboard.on('success', function(){
swal({
title: "",
text: '复制成功',
icon: "success",
showConfirmButton: true
});
});
});
</script>

		
	</div>

    <footer class="post-footer">
          <div class="reward-container">
  <div></div>
  <button>
    赞赏
  </button>
  <div class="post-reward">
      <div>
        <img src="/images/wx.png" alt="hyw-zero 微信">
        <span>微信</span>
      </div>
      <div>
        <img src="/images/alipay.png" alt="hyw-zero 支付宝">
        <span>支付宝</span>
      </div>

  </div>
</div>

          <div class="post-tags">
              <a href="/tags/vim/" rel="tag"><i class="fa fa-tag"></i>vim</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2019/02/11/Qt%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0%E4%B9%8Bsocket%E9%80%9A%E4%BF%A1/" rel="prev" title="Qt学习笔记之socket通信">
                  <i class="fa fa-chevron-left"></i> Qt学习笔记之socket通信
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/2019/05/01/linux%E8%BF%9B%E7%A8%8B%E9%80%9A%E4%BF%A1-%E5%85%B1%E4%BA%AB%E5%86%85%E5%AD%98/" rel="next" title="Linux进程通信(共享内存)">
                  Linux进程通信(共享内存) <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






    <div class="comments" id="lv-container" data-id="city" data-uid="MTAyMC80MzU4NC8yMDEyMw=="></div>
</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 2018 – 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">hyw-zero</span>
</div>
<div class="busuanzi-count">
    <span class="post-meta-item" id="busuanzi_container_site_uv">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-item" id="busuanzi_container_site_pv">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>
<div class="theme-info">
	<i class="fa fa-edit" style="font-size:18px"></i>
	<span class="post-count">博客全站共98.2k字</span>
</div>
    </div>
  </footer>

  
  <script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script>

  
<script src="/js/third-party/search/local-search.js"></script>



  <script class="next-config" data-name="nprogress" type="application/json">{"enable":true,"spinner":true}</script>
  <script src="/js/third-party/nprogress.js"></script>

  
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>




<script src="/js/third-party/comments/livere.js"></script>
</body>
<!-- 页面点击小红心 -->
<script type="text/javascript" src="/js/love.js"></script>
</html>

